//
//  AppStatus.m
//  BrushFace
//
//  Created by timer_q on 16/1/22.
//  Copyright © 2016年 Zzz. All rights reserved.
//

#import "AppStatus.h"
#import "DeviceInfo.h"

#define KEY_UPLOAD_ADDRESSBOOK_TIME @"upload_addressbook_time"

@implementation AppStatus

DEF_SINGLETON(AppStatus)

+ (void)saveUploadAddressbook{
    NSString *timeStr = [NSString stringWithFormat:@"%ld",[[DeviceInfo getCurDeviceTimeStr] integerValue]/1000];
    [[NSUserDefaults standardUserDefaults] setObject:timeStr forKey:KEY_UPLOAD_ADDRESSBOOK_TIME];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+ (BOOL)whetherUploadAddressBook{
    NSInteger time = 604800;
    NSString *saveTimeStr = [[NSUserDefaults standardUserDefaults] objectForKey:KEY_UPLOAD_ADDRESSBOOK_TIME];
    if (saveTimeStr.isNotEmpty) {
        NSInteger currentTime = [[DeviceInfo getCurDeviceTimeStr] integerValue]/1000;
        NSInteger saveTime = [saveTimeStr integerValue];
        if (saveTime-currentTime>time) {
            return YES;
        }else{
            return NO;
        }
    }else{
        return YES;
    }
}
+ (void)removeAddressBook{
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:KEY_UPLOAD_ADDRESSBOOK_TIME];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+ (BOOL)judgeAPPFristLaunch{
    NSUserDefaults *userdefault = [NSUserDefaults standardUserDefaults];
    if ([[userdefault objectForKey:@"firstlaunch"] isNotEmpty]) {
        return NO;
    }else{
        [userdefault setObject:@"123" forKey:@"firstlaunch"];
        [userdefault synchronize];
        return YES;
    }
}
@end
